package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.GoodsService;
import com.example.dao.UserDao;
import com.example.entity.User;
import com.example.service.OrderService;
import com.example.service.UserService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * (User)表服务实现类
 *
 * @author makejava
 * @since 2023-01-31 13:54:27
 */
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {

    @Autowired
    private OrderService orderService;
    @Autowired
    private GoodsService goodsService;
    @Override
    @Transactional
//加上这个注解，开启Seata分布式事务
    @GlobalTransactional
    public void test() {
        User user = new User();
        user.setId(1);
        user.setName("张三");
        int insert = baseMapper.insert(user);
        int i = orderService.addOrder();
        int add = goodsService.add();
    }
}

